package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductSku;
import com.nbsaas.boot.product.api.domain.simple.ProductSkuSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 商品SKU-列表对象转换器
*/

public class ProductSkuSimpleConvert implements Converter<ProductSkuSimple, ProductSku> {




@Override
public ProductSkuSimple convert(ProductSku source) {
    ProductSkuSimple result = new ProductSkuSimple();

                result.setNote(source.getNote());

               try {
                   if(source.getProduct()!=null){
                       result.setProduct(source.getProduct().getId());
                   }
                } catch (Exception ignored) { }

                result.setCode(source.getCode());
                result.setIcon(source.getIcon());
                result.setStandardPrice(source.getStandardPrice());
                result.setAddDate(source.getAddDate());

                try {
                    if(source.getProduct()!=null){
                        result.setProductName(source.getProduct().getName());
                    }
                } catch (Exception ignored) { }

                result.setPrice(source.getPrice());
                result.setName(source.getName());
                result.setRealStock(source.getRealStock());
                result.setId(source.getId());
                result.setStock(source.getStock());
                result.setLastDate(source.getLastDate());


    return result;
}

}